<%@ include file="/webapis/ui/doctype.jspf" %>

<%@ taglib uri="/bbNG" prefix="bbNG"%>
<%@ taglib uri="/bbData" prefix="bbData"%>
<%@ taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core" %>  
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %> 

<script src="../dist/js/jquery-3.1.1.min.js" type="text/javascript"></script>

<fmt:setLocale value="${locale}"/> 
<fmt:bundle basename="messages"/>
<bbNG:genericPage>

<bbNG:jsBlock>
<script type="text/javascript">
jQuery.noConflict();
var bbCls = document.getElementsByName("bbCls");
var bbAttr = document.getElementsByName("bbAttr");
var modelCls = document.getElementsByName("modelCls");
var modelAttr = document.getElementsByName("modelAttr");

var bbClsOption = jQuery("#bbClsOption");
var bbAttrOption = jQuery("#bbAttrOption");
var modelClsOption = jQuery("#modelClsOption");
var modelAttrOption = jQuery("#modelAttrOption");

function save(){	
	var importParam = "[";
	for(var i = 0; i < bbCls.length; i++){
		var param = {
            "bbClsName" : bbCls[i].value,
            "bbAttribute" : bbAttr[i].value,
            "modelClsName" : modelCls[i].value,
            "modelAttribute" : modelAttr[i].value
	        };
		var obj = JSON.stringify(param);
		importParam+=obj+",";
	}
	importParam = importParam.substring(0, importParam.length-1);
	importParam+="]";
	jQuery.ajax({
    	async: false,
        url: "../extention/set",    
        contentType:"application/json",   
        dataType: "text",
        type: "POST",
        data:importParam,     
        success: function (result) {
           alert(result);
    },
       error: function (e) {
          alert("failed");
       }
    });
}

</script>
</bbNG:jsBlock>

<bbNG:breadcrumbBar  environment="sys_admin" navItem="admin_main">
<fmt:message key="index" var="index"/>
<bbNG:breadcrumb href="../index">index</bbNG:breadcrumb>
</bbNG:breadcrumbBar>

<bbNG:actionControlBar>
<fmt:message key="set.extention" var="title"/>
<bbNG:actionButton id="setAction" url="../extention/load" title="${title}" onClick = "save()" primary="true"/>

</bbNG:actionControlBar>
 
<form id = "listForm" method = "post" action="../extention/set">
<bbNG:inventoryList collection="${extentionModelList}" objectVar="model" className="cn.com.blackboard.DataModule4B2.util.ExtentionModel" url="">

<fmt:message key="set.extention.bbCls" var="bbCls"/>
<fmt:message key="set.extention.bbAttr" var="bbAttr"/>
<fmt:message key="set.extention.modelCls" var="modelCls"/>
<fmt:message key="set.extention.modelAttr" var="modelAttr"/>
<bbNG:listElement label="${bbCls}" name="bbCls" isRowHeader="true">
	
	<input NAME="bbCls"  VALUE="${model.getBbClsName()}">
</bbNG:listElement>
<bbNG:listElement label="${bbAttr}" name="bbAttr">
	
	<input NAME="bbAttr"  VALUE="${model.getBbAttribute()}">
</bbNG:listElement>
<bbNG:listElement label="${modelCls}" name="modelCls">
	
	<input NAME="modelCls"  VALUE="${model.getModelClsName()}">
</bbNG:listElement>
<bbNG:listElement label="${modelAttr}" name="modelAttr">
	
	<input NAME="modelAttr"  VALUE="${model.getModelAttribute()}">
</bbNG:listElement>

</bbNG:inventoryList>
</form>

<fmt:message key="strButOk" var="strButOk"/>
<bbNG:button id = "refreshBtn" type="PageLevel" label="${strButOk}" url="../index"/>



</bbNG:genericPage>


